﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        var aa = OnlineexamHelper.context.tbllogins.Where(a => a.email == txtUserName.Text && a.password == txtPwd.Text);
        if (aa.Count() > 0)
        {
            foreach (var item in aa)
            {
                Session["UserId"] = item.Id;
                Session["role"] = item.Fk_role_id;
                Session["Username"] = item.fname;
            }
            if (Convert.ToInt32(Session["role"]) == 4080363)
            {
                Response.Redirect("Adminhome.aspx");
            }
            else if(Convert.ToInt32(Session["role"])==123)
            {
                Response.Redirect("PaidUser.aspx");
            }
            else if (Convert.ToInt32(Session["role"]) == 12345)
            {
                Response.Redirect("TutorHome.aspx");
            }
            else if(Convert.ToInt32(Session["role"])==1)
            {
                Response.Redirect("UserHome.aspx");
            }
        }
        else
        {
            Response.Write("<script>alert('Invalid Login')</script>");
        }
    }
    protected void lnkSignUp_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }

}